package cn.hfuu.service.impl;

import cn.hfuu.dao.CustomerDao;
import cn.hfuu.domain.Customer;
import cn.hfuu.service.CustomerService;
import cn.hfuu.utils.PageBean;
import org.hibernate.criterion.DetachedCriteria;

import java.util.List;

public class CustomerServiceImpl implements CustomerService{

    private CustomerDao customerDao;

    @Override
    public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) {

        //调用dao层方法查询总记录数
        Integer totalCount = customerDao.getTotalCount(dc);
        //查询当前页面显示列表

        PageBean pb = new PageBean(totalCount,currentPage,pageSize);

        List<Customer> list = customerDao.getPageList(dc,pb.getStart(),pb.getPageSize());
        pb.setList(list);

        return pb;
    }

    public void setCustomerDao(CustomerDao customerDao) {
        this.customerDao = customerDao;
    }
}
